<template>
  <div class="news">
    <!-- 顶部横幅 -->
    <div class="banner">
      <h1>NEWS</h1>
    </div>

    <div class="detail-content" v-if="newsItem">
      <div class="detail-header">
        <p class="meta">
          <span class="date">{{ newsItem.subtitle }}</span>
          <!-- |<span class="category">{{ newsItem.category }}</span> -->
        </p>
        <h2>{{ newsItem.title }}</h2>
        <hr class="divider-line" />
      </div>

      <!-- 新增正文内容区域 -->
      <div class="detail-body">
        <div v-if="newsItem.content" v-html="newsItem.content"></div>
        <p v-else>暂无详细内容</p>

        <button @click="$router.go(-1)" class="back-button">
          &lt; 一覧へ戻る
        </button>
      </div>
     
    </div>
  </div>
</template>

<script>
export default {
  props: ['id', 'newsData'],
  data() {
    return {
      newsItem: this.newsData || {}
    };
  },
  mounted() {
    console.log("Received id:", this.id);
    console.log("Received newsData:", this.newsItem);
  },
  // 移除 stripHtmlTags 方法，因为不再需要清理 HTML 标签
};
</script>

<style scoped>
/* 详情页面样式 */
.news-detail {
  padding: 40px;
  background: linear-gradient(to bottom, #fef7ed, #fde5e5);
}

.banner {
  background: url("@/assets/1846501c44ee4d889c34bda06571b3e0.png") no-repeat
    center/cover;
  text-align: center;
  padding: 60px 0;
  color: #8d6e52;
}

.banner h1 {
  text-align: center;
  font-size: 36px;
  margin: 40px 0;
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif; /* 添加黑体字体 */
  font-weight: 400; /* 取消加粗 */
  color: #666;
}

.news {
  min-height: 85vh;
  display: flex;
  flex-direction: column;
}

.detail-content {
  flex: 1;
  /* 保持原有其他样式 */
  max-width: 1200px;
  margin: 40px auto;
  text-align: left;
}

.detail-header h2 {
  font-size: 26px;
  font-weight: normal; /* 修改此处，从bold改为normal */
  color: #666;
}

.detail-header p {
  font-size: 22px; /* 从14px改为22px */
  color: #666;
}

.image-section img {
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.detail-body h3 {
  font-size: 22px;
  font-weight: bold;
}

.detail-body p {
  color: #666;
  font-family: "Ming", serif;
  line-height: 1.8;
  margin-bottom: 1.5em;
}

.detail-body {
  position: relative;
}

.back-button {
  margin-top: 30px;
  padding: 10px 20px;
  background-color: #f8d7a3;
  color: #666;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  transition: background-color 0.3s;
}

.back-button:hover {
  background-color: #f5b8ca;
}

.divider-line {
  border: none;
  height: 1px;
  background-color: #f8d7a3; /* 与按钮相同的颜色 */
  margin: 20px 0;
}
.listBox_l_iocns {
  display: flex;
  flex-direction: column;
  margin-top: 20px;
}

.listBox_l_iocns > div {
  display: flex;
  gap: 15px;
  margin-top: 10px;
}
.listBox_l_iocns img {
  width: 63px;
  height: 60px;
  margin: 0 10px;
}
</style>
